<template>
    <!-- 遮罩层 -->
    <div v-if="visible" class="overlay" @click="closeModal"></div>

    <!-- 弹窗 -->
    <div v-if="visible" class="modal">
        <div class="modal-title">
            <img src="../assets/me_home/dingweimao.png" alt="">
            <div class="title-text">{{ bianObj.obj.name }} </div>
            <span class="close-btn" @click="closeModal">&times;</span>
        </div>
        <div class="modal-con">
            <div class="con-item" @click="openBianZhan(bianObj)" style="cursor: pointer;">
                <img src="../assets/me_home/guizi.png" alt="" style="width: 94px;height: 85px;">
                <div class="nameBox">
                    <div class="name">变电站名称：工厂变电站</div>
                    <div class="name">变电柜数量：12</div>
                    <div class="number">安装时间：{{ bianObj.time }}</div>
                </div>
            </div>
            <div class="con-item" @click="openBianZhan(bianObj)" style="cursor: pointer;">
                <img src="../assets/me_home/guizi.png" alt="" style="width: 94px;height: 85px;">
                <div class="nameBox">
                    <div class="name">变电站名称：测试变电站</div>
                    <div class="name">变电柜数量：5</div>
                    <div class="number">安装时间：2025-01-21 10:53Am</div>
                </div>
            </div>
        </div>

    </div>
</template>

<script setup>
import { defineProps, defineEmits } from 'vue';

// 定义 props
const props = defineProps({
    visible: {
        type: Boolean,
        default: false,
    },
    // title: {
    //     type: String,
    //     default: '弹窗标题',
    // },
    bianObj: {
        type: Object,
        default: {}
    }
});

// 跳转ue模型关卡
const openBianZhan = (obj) => {
    ue5("openBianZhan", obj.title)
    console.log("=====>", obj)
}

// 定义 emits
const emit = defineEmits(['update:visible']);

// 关闭弹窗
const closeModal = () => {
    emit('update:visible', false);
};
</script>

<style scoped lang="scss">
/* 遮罩层 */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* 弹窗 */
.modal {
    position: fixed;
    top: 100px;
    /* 垂直居中 */
    right: 20px;
    /* 与右侧保持 20px 间距 */
    // transform: translateY(-50%); /* 垂直居中 */
    width: 400px;
    /* 设置宽度 */
    padding: 20px;
    /* 内边距 */
    background: #000000;
    /* 背景颜色 */
    border: 1px solid #565454;
    /* 边框 */
    border-radius: 10px;
    /* 圆角 */
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    /* 阴影 */
    z-index: 1000;
    /* 层级 */
}

.modal-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #323332;
    padding: 10px 20px;
    box-sizing: border-box;

    img {
        width: 35px;
        height: 35px;
    }

    .title-text {
        margin-left: 10px;
        font-size: 16px;
        width: 300px;
    }
}

.modal-con {
    background-color: #202121;
    width: 100%;
    // height: 180px;

    .con-item {
        border-bottom: 1px solid #585757;
        width: 100%;
        height: 150px;
        display: flex;
        // flex-direction: column;
        align-items: center;
        justify-content: space-around;

        .nameBox {
            // border: 1px solid #ffffff;
            padding-top: 20px;
            width: 250px;
            height: 100%;
            display: flex;
            flex-direction: column;
            justify-content: center;
            .name {
                width: 100%;
                color: #c9cdcd;
                font-size: 18px;
                margin-top: 5px;
            }

            .number {
                width: 100%;
                height: 60px;
                font-size: 16px;
                margin-top: 5px;
                // font-weight: bold;
            }
        }

        .timetext {
            width: 100%;
            height: 60px;
            text-align: center;
            font-size: 18px;
            font-weight: bold;

        }
    }

    // .con-item + .con-item{
    //     border-left: 1px solid #373535;
    // }
}

/* 关闭按钮 */
.close-btn {
    float: left;
    cursor: pointer;
    font-size: 26px;
    font-weight: bold;
    // width: 220px;
    text-align: right;
}
</style>